package com.playjoy.service;

import com.playjoy.dao.UserRepository;
import com.playjoy.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;

/**
 * Created by asus on 2016/11/8.
 */
@Service
public class SysUserService {
    @Resource
    private  UserRepository  userRepository;

    @Transactional
    public void  save (User user){
        userRepository.save(user);
    }

    @Transactional
    public User get(String  name){
        System.out.println("*******查询所有***********");
        // fetch all customers
        for (User user : userRepository.findAll()) {
            System.out.println(user.getName());
        }
        User user =  userRepository.findByName(name);
            System.out.println("*******单个***********");
            System.out.println(user.getName());
        return user;
    }
/*    @Transactional
    public SysUser findUser(String  userName){
        SysUser user =  userRepository.findUser(userName);
        return user;
    }*/

}
